<?php
/**
 * Created by PhpStorm.
 * User: 驭风者
 * Date: 2019/8/14
 * Time: 16:30
 */
namespace app\index\controller;
use think\Controller;
use think\Request;
use think\Session;

class Common extends Controller
{
    public function __construct()
    {
        $controller = Request::instance()->controller();
        $action = Request::instance()->action();
        $url = strtolower($controller).'/'.strtolower($action);

        $power = Session::get('power');

        $url_power = [];
        foreach($power as $k=>$v)
        {
            if($v['url'])
            {
                $url_power[] = strtolower($v['url']);
            }
        }

        if(!in_array($url,$url_power))
        {
            $this->error('没有访问权限,请联系管理员!');
        }
    }
}















?>